using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Drawing;
using System.Reflection;
using DevExpress.XtraGrid;
using DevExpress.XtraEditors;
using THSLib;

namespace THSERP.BaseProvider
{
    public partial class THSDateEdit : DevExpress.XtraEditors.DateEdit
    {
        #region Variables
        protected String _THSDataSource;
        protected String _THSDataMember;
        protected String _THSPropertyName;
        protected String _THSFieldGroup;
        protected String _THSComment;
        protected THSERPScreen _screen;
        protected String _THSError;
        protected String _THSPrivilege;
        #endregion

        #region Public Properties    
        public THSERPScreen Screen
        {
            get
            {
                return _screen;
            }
            set
            {
                _screen = value;
            }
        }

        [Category("THS")]
        public String THSDataSource
        {
            get
            {
                return _THSDataSource;
            }
            set
            {
                _THSDataSource = value;
            }
        }

        [Category("THS")]
        public String THSDataMember
        {
            get
            {
                return _THSDataMember;
            }
            set
            {
                _THSDataMember = value;
            }
        }

        [Category("THS")]
        public String THSPropertyName
        {
            get
            {
                return _THSPropertyName;
            }
            set
            {
                _THSPropertyName = value;
            }
        }

        [Category("THS")]
        public String THSFieldGroup
        {
            get
            {
                return _THSFieldGroup;
            }
            set
            {
                _THSFieldGroup = value;
            }
        }

        [Category("THS")]
        public String THSComment
        {
            get
            {
                return _THSComment;
            }
            set
            {
                _THSComment = value;
            }
        }

        [Category("THS")]
        public String THSError
        {
            get
            {
                return _THSError;
            }
            set
            {
                _THSError = value;
            }
        }

        [Category("THS")]
        public String THSPrivilege
        {
            get
            {
                return _THSPrivilege;
            }
            set
            {
                _THSPrivilege = value;
            }
        }
        #endregion

        #region Constructor
        public THSDateEdit()
        {
            InitializeComponent();
        }

        public THSDateEdit(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }
        #endregion

        #region--Initialize--
        public void InitializeControl()
        {
            if (this.Name.Contains("SearchFrom") || this.Name.Contains("SearchTo"))
            {
                if (Tag.ToString() == THSERPScreen.SearchControl)
                {
                    if (this.Name.Contains("SearchFrom"))
                        this.EditValue = THSUtil.GetYearBeginDate();
                    else if (this.Name.Contains("SearchTo"))
                        this.EditValue = THSUtil.GetYearEndDate();
                }
            }
            if (!String.IsNullOrEmpty(this.THSDataSource) && !String.IsNullOrEmpty(this.THSDataMember))
                Screen.BindingDataControl(this);

            this.Click += ((BaseModuleERP)Screen.Module).Control_Click;
            this.KeyUp += new KeyEventHandler(((BaseModuleERP)Screen.Module).Control_KeyUp);
        }
     #endregion
    }
}
